package impresion;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import java.util.List;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

public class PanelJuego  extends JFrame {
    /**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JPanel contentPane;
	private int size;
	private List<Color> colores;
	
	private Image tesoro = new ImageIcon(getClass().getResource("tesoro.gif")).getImage();
	private Image daniel = new ImageIcon(getClass().getResource("daniel.jpg")).getImage();
	private Image hernan = new ImageIcon(getClass().getResource("hernan_melgratti.png")).getImage();


    public PanelJuego(int size){
    	this.size = size;
    	this.refresh();
    }
    
    public void refresh(){
    	setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setBounds(100, 100, 450, 300);
        contentPane = new JPanel();
        contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
        setContentPane(contentPane);
        setBounds(0,0,500,500);
    }
    
    public void paint (Graphics g){
    	super.paint(g);
    	int posX = 30;
    	int posY = 0;
    	int index = 0;
    	for(int fila = 0; fila<size;++fila){
    		posY += 50;
    		posX = 30;
    		for(int columna = 0;columna<size;++columna){
    			if(colores.get(index)!= Color.gray){

    				//Cuando imprimia lo colores
    				//g.setColor(colores.get(index));
    				//g.fillRect (posX, posY, 50, 50);

    				if(Color.green == colores.get(index)){
    					g.drawImage(hernan, posX, posY, 50, 50,this);
    				}
    				if(Color.blue == colores.get(index)){
    					g.drawImage(daniel, posX, posY, 50, 50,this);
    				}
    				if(Color.yellow == colores.get(index)){
    					g.drawImage(tesoro, posX, posY, 50, 50, this);
    				}
    				
    			}
    			index ++;
    			
    			g.setColor(Color.black);
    			g.drawLine(posX, posY, posX, posY+50);
    			g.drawLine(posX, posY+50, posX+50, posY+50);
    			g.drawLine(posX+50, posY+50, posX+50, posY);
    			g.drawLine(posX+50, posY, posX, posY);
    			
    			posX += 50;
    			}
    		}
    }
    

	public void setColores(List<Color> cs) {
		this.colores = cs;
	}
	
   
}
